<?=plugin\laoha\app\common\Template::header($title??'老蟹CMS')?>
<?=plugin\laoha\app\common\Template::nav('default',$active??'/')?>


<div class="container py-3 pb-0">
    <?=plugin\laoha\app\common\Template::bread($bread??'')?>
</div>
<div class="container content">
    <div class="row">
        <div class="col-lg-8 mb-4">
            <div class="card shadow-sm p-4 mb-4 rounded-0">
                <center>
                    <h4>
                        <?=htmlspecialchars($data['title'])?>
                    </h4>
                    <p class="fw-light">
                        <?=$data['created_at']?>
                    </p>
                    <hr />
                </center>

                <div id="content" class="lh-lg" data-root-id="<?=$data['id']?>" data-root="post">

                    <?=$data['content']?>
                    <div class="lightbox"
                        data-plugin-options="{'delegate': 'a', 'type': 'image', 'gallery': {'enabled': true}, 'mainClass': 'mfp-with-zoom', 'zoom': {'enabled': true, 'duration': 300}}">
                        <?php if(!empty($data['images'])){ ?>
                        <?=plugin\laoha\app\common\Template::images($data['images'])?>
                        <?php } ?>
                    </div>
                    <?php if(!empty($data['attaches'])){ 
                        echo "<hr><h6>附加文件，点击下载</h6>";
                        $files = str2arr($data['attaches']);
                        foreach($files as $f){
                            $d=basename($f);
                            echo "<a href='$f' download='$d'>$d</a><br/>";
                        }
                    }
                    ?>
                    <p class="fs-6 fw-lighter text-muted mt-4">
                        <i class="far fa-clock"></i>
                        <?=timeTo($data['created_at'])?>&nbsp;&nbsp;&nbsp;&nbsp;
                        <i class="far fa-paper-plane"></i>
                        <?=$data['views']?> 阅读&nbsp;&nbsp;&nbsp;&nbsp;
                        <?=isset($data['comments_count']) ?  '<i class="far fa-comment-dots"></i> <span id="comments_count">'.$data['comments_count'].'</span> 评论&nbsp;&nbsp;&nbsp;&nbsp;' : '' ?>
                        <a href="javascript:" onclick="add(this, '/app/laoha/post/add?field=goods&id=<?=$data['id']?>')"
                            class="link-underline-light add-goods text-black"><i class="far fa-heart"></i> <span>
                                <?=$data['goods']?>
                            </span> 点赞&nbsp;&nbsp;&nbsp;&nbsp;</a>
                        <?php if(user_id()){ ?>
                        <a href="javascript:" onclick="act(this,'/app/laoha/post/act?root=post&id=<?=$data['id']?>','collect')"
                            class="link-underline-light act-collect text-black"><i
                                class="fa fa-star act <?=$data['collect']?'':'d-none'?>"></i><i
                                class="far fa-star acted <?=$data['collect']?'d-none':''?>"></i> 收藏</a>
                        <?php } ?>
                    </p>
                    <div class="my-3">
                        <hr />
                        <p>
                            <a href="/app/laoha/post/detail?id=<?=$data['id']?>&_pre=1" class="link-underline-light">< 上一篇</a>
                            <a href="/app/laoha/post/detail?id=<?=$data['id']?>&_next=1" class="float-end link-underline-light">下一篇 ></a>
                        </p>
                    </div>                    
                    <?php if(!empty($data['status'])){ ?>
                    <div id="post-check">
                        <hr />
                        <p class="text-danger text-center">此文尚未通过审核
                            <?php if(!empty($rules['manage'])){ ?>
                            ，<a href="javascript:;"
                                onclick="check('/app/laoha/admin/post/check?status=0&id=<?=$data['id']?>','post-check')">点此通过审核</a>
                            <?php } ?>
                        </p>
                    </div>
                    <?php } ?>
                </div>
            </div>

            <?php if(!empty($config['comment'])) echo \plugin\laoha\app\common\Template::comments($config,$data['id']); ?>


        </div>

        <div class="col-lg-4 mb-4">
            <div class="card shadow-sm mb-4 p-3 rounded-0">
                <div class="fw-bolder fs-5">文章搜索</div>
                <?=plugin\laoha\app\common\Template::search()?>
            </div>

            <div class="card shadow-sm mb-4 p-3 rounded-0">
                <div class="fw-bolder fs-5 mb-3">热门内容</div>
                <?=plugin\laoha\app\common\Template::list(['per_page'=>6,'order_by'=>'-views'],true)?>
            </div>
            <div class="card shadow-sm mb-4 p-3 rounded-0">
                <div class="fw-bolder fs-5 mb-3">推荐内容</div>
                <?=plugin\laoha\app\common\Template::list(['per_page'=>8,'pos'=>'推荐'])?>
            </div>
        </div>
    </div>
</div>
<?=plugin\laoha\app\common\Template::footer()?>